#include "Eventloop.h"
#include "TcpServer.h"
#include "Tcpconnection.h"
using namespace std;
using namespace liu;
class EchoServer
{
public:
	EchoServer(Eventloop* pLoop)
		:m_pLoop(pLoop),
		m_server(pLoop)
	{
		m_server.m_ConnectionCallback = bind(&EchoServer::onConnection, this, placeholders::_1);
	}

	void onConnection(const shared_ptr<TcpConnection>& conn)
	{
		cout << debug_time() << "EchoServer::onConnection call" << endl;
	}


	void onMsg(const shared_ptr<TcpConnection>& conn, const string& msg)
	{
		conn->send(msg);
	}

	void start()
	{
		m_server.start();
	}

public:
	Eventloop* m_pLoop;
	TcpServer m_server;

};

int main()
{	
	Eventloop loop;
	EchoServer server(&loop);
	server.start();
	loop.Loop();

	return 0;
}